package com.heima.comment.feign;

import com.heima.comment.service.CommentService;
import com.heima.feign.comment.ICommentClient;
import com.heima.model.comment.pojos.CommentLikeDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.AuthorLikeDto;
import com.heima.model.wemedia.dtos.CommentListDto;
import com.heima.model.wemedia.dtos.WmRepayCommentDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommentClient implements ICommentClient {
    @Autowired
    private CommentService commentService;
    /**
     * 评论详情
     * @param dto
     * @return
     */
    @PostMapping("/api/v1/comment/list")
    @Override
    public ResponseResult list(@RequestBody CommentListDto dto) {
       return commentService.list(dto);
    }

    /**
     * 作者点赞或取消评论
     *
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/api/v1/comment/authorLike")
    public ResponseResult like(@RequestBody AuthorLikeDto dto) {
        return commentService.authorLike(dto);
    }

    /**
     * 作者回复评论
     *
     * @param dto
     */
    @Override
    @PostMapping("/api/v1/comment/repay")
    public ResponseResult repay(@RequestBody WmRepayCommentDto dto) {
        return commentService.repay(dto);
    }
}
